< previous page page_115 next page >

Page 115
Puzzle 25
Universal Identifiers, Part 1
You've probably heard of COM, the Component Object Model. You may have heard of it by other terms such as ActiveX or OLE. COM is an object modela way to create and utilize a certain type of object called a "Windows object." (An in-depth introduction to COM from the perspective of Visual Basic programmers can be found in my book Dan Appleman's Developing COM/ActiveX Components for Visual Basic 6.0: A Guide to the Perplexed.)
The Win32 API includes hundreds of functions that relate to COM. These functions are part of the OLE subsystem. (OLE stands for Object Linking and Embedding. It is the technology that implements COM objects. ActiveX is another name for OLE.)
Every COM object is identified by a universal identifier called a GUID, or Globally Unique Identifier. This is a 128-bit number unique to the object in question. Due to the way GUIDs are created, the odds of another object sharing the same GUID are vanishingly remote. When you read the OLE documentation, you will also see the terms UUID, CLSID, and IID, for Universally Unique Identifier, Class Identifier, and Interface Identifier, respectively. The differences among these are purely semantic. In other words, the only difference between a class identifier and an interface identifier is that one identifies a class and the other identifies an interface. They are all 128-bit numbers and can be operated on identically from the programmer's perspective.
Puzzles 2528 will demonstrate how to work with the OLE subsystem and GUIDs. But before you can deal with a GUID, you must know how to represent it in Visual Basic. Neither Visual Basic nor C++ have a 128-bit data type.
Here's a section from the Windows header file wtypes.h that includes the C++ declarations for GUIDs, CLSIDs, and IIDs:
#ifndef GUID_DEFINED
#define GUID_DEFINED
typedef struct _GUID
    {
    DWORD Datal;
    WORD Data2;
    WORD Data3;

 
< previous page page_115 next page >